package org.vacoor.ticket.bean.param.impl;

import java.text.SimpleDateFormat;

import org.vacoor.ticket.bean.TicketDto;
import org.vacoor.ticket.bean.TrainType;
import org.vacoor.ticket.bean.param.Parameter;

/**
 * 封装预订车票的基本参数
 */
public class BookingParam implements Parameter {
	
	private TicketQueryParam query;
	private TicketDto dto;
	
	public BookingParam(TicketQueryParam ticketQuery,TicketDto dto) {
		this.query = ticketQuery;
		this.dto = dto;
	}

	public TicketQueryParam getTicketQuery() {
		return query;
	}

	public void setTicketQuery(TicketQueryParam ticketQuery) {
		this.query = ticketQuery;
	}

	public TicketDto getDto() {
		return dto;
	}

	public void setDto(TicketDto dto) {
		this.dto = dto;
	}

	@Override
	public String getQueryString() {
		String tmp = "";
		for(TrainType t : query.getTrainType()) {
			tmp += t.getValue();
		}
		return 
				//这些信息在查询信息中含有
				"include_student=" + (query.isStuQuery() ? "0x00" : "00") +
				"&start_time_str=" + query.getTimeRegion().getValue() +		//列车时间段
				"&round_start_time_str=" + query.getTimeRegion().getValue() +
				"&train_date=" + new SimpleDateFormat("yyyy-MM-dd").format(query.getTrainDate()) + //列车日期
				"&round_train_date=" + new SimpleDateFormat("yyyy-MM-dd").format(query.getTrainDate()) +
				"&seattype_num=" +						//席别、数量的集合，采用席别#数量@,改版后取消了好像
				"&single_round_type=1" +
				"&train_class_arr=" + tmp + //列车类型
				"&train_pass_type=" + query.getTrainPassType().getValue() +					//列车经过类型
				
				//
				"&from_station_telecode_name=" + dto.getFromStationName() +
				"&to_station_telecode_name=" + dto.getArriveStationName() +
				//以下信息均可从查询返回的结果中获取
				"&station_train_code=" + dto.getTrainCode() +		//车次
				"&lishi=" + dto.getCountTime() +				//历时
				"&train_start_time=" + dto.getStartTime() +	//出发站发车时间
				"&trainno4=" + dto.getTrainNo() +		//列车编号
				"&from_station_telecode=" +	dto.getFromStationCode() + //出发站代码
				"&to_station_telecode=" + dto.getArriveStationCode() +	//目的站代码
				"&arrive_time=" + dto.getEndTime() +			//目的站到达时间
				"&from_station_name=" +	dto.getFromStationName() +	//出发站名称
				"&to_station_name=" + dto.getArriveStationName() +		//目的站代码
				"&from_station_no=" +	dto.getFromStationNo() +		//
				"&to_station_no=" +	dto.getArriveStationNo() +		//
				"&ypInfoDetail=" + dto.getRemainTicketsDetail() + //运行详情
				"&mmStr=" + dto.getMmStr() + //
				"&locationCode=" + dto.getLocationCode();		//
	}
}
